#define _CRT_SECURE_NO_WARNINGS 1
#include <string>
#include <stack>
using namespace std;
class Solution {
public:
    string removeDuplicates(string s)
    {
        stack<char> q;
        for (int i = 0;i < s.size();i++)
        {
            if (q.empty())
            {
                q.push(s[i]);
            }
            else
            {
                auto t = q.top();
                if (s[i] == t) q.pop();
                else q.push(s[i]);
            }
        }
        string ret(q.size(), '0');
        for (int i = ret.size() - 1;i >= 0;i--)
        {
            ret[i] = q.top();
            q.pop();
        }
        return ret;
    }
};